/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package data;

import entities.Artwork;
import java.util.LinkedList;

/**
 *
 * @author bertram
 */
public class WorkCache {
    private static LinkedList<Artwork> works = new LinkedList<Artwork>();

    public static synchronized void addWork(Artwork work)
    {
        works.add(work);
        if(works.size() > 100)
        {
            works.removeFirst();
        }
    }

    public static Artwork getWork(int workID)
    {
        for(Artwork a: works)
        {
            if(a.getWorkID() == workID) return a;
        }
        return new Artwork(workID);
    }

    public static boolean contains(int workID)
    {
        boolean contains = false;
        for(Artwork a : works)
        {
            if(a.getWorkID() == workID) contains = true;
        }
        return contains;
    }

}
